<!doctype html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <title></title>
    <meta name="format-detection" content="telephone=no" />
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/common.css" />
    <style>
        /* 头部样式 */

        .topbar {
            background: #3A8B7A;
            height: 50px;
        }

        #title {
            color: #FFF;
        }

        .swipe {
            line-height: 50px;
            margin-right: 10px;
            color: #FF8400;
        }

        .back {
            float: left;
            padding-right: 30px;
        }

        .back img {
            height: 30px;
            margin-top: 10px;
            margin-left: 10px;
        }

        .topbar .title {
            line-height: 50px;
            font-size: 22px;
            position: absolute;
            left: 50%;
            -webkit-transform: translateX(-50%);
            transform: translateX(-50%);
        }

        .right {
            float: right;
            padding-left: 30px;
        }

        .right img {
            height: 30px;
            margin-top: 10px;
            margin-right: 10px;
        }

        #wrapper {
            position: relative;
            z-index: 1;
            height: 35px;
            width: 96%;
            padding-top: 1px;
            border-bottom: 1px solid #E5E5E5;
        }

        #scroller {
            position: absolute;
            z-index: 1;
            -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
            width: 200%;
            -webkit-transform: translateZ(0);
            transform: translateZ(0);
            -webkit-touch-callout: none;
            -webkit-user-select: none;
            -webkit-text-size-adjust: none;
            border-top: 1px solid #E5E5E5;
        }

        #scroller ul {
            list-style: none;
            padding: 0;
            margin: 0;
            display: -webkit-box
        }

        #scroller li {
            /*width: 12%;*/
            margin-left: 20px;
            line-height: 35px;
            font-size: 16px;
            overflow: hidden;
            text-align: center;
        }
        /*
            iscroll
        */

        .nav_active {
            color: #3A8B7A;
            font-size: 18px !important;
            border-bottom: 2px solid #3A8B7A;
        }

        .nav_active span {
            color: #3A8B7A;
            font-size: 18px !important;
        }

        nav {
            width: 100%;
            display: -webkit-box;
            background-color: #ECECEC;
        }

        .arrow_down {
            display: block;
            background-size: 15px;
            background-repeat: no-repeat;
            background-position: center;
            padding: 15px;
            background-image: url('../image/channel_nav_arrow@2x.png');
            -webkit-box-flex: 1;
            -webkit-transform: rotate(90deg);
            -webkit-transition: All .5s ease;
        }

        .arrow_up {
            /*-webkit-transform: rotate(0deg);
            -webkit-transition: All .5s ease;*/
        }
    </style>
</head>

<body>
    <div id="wrap">
        <nav>
            <div id="wrapper">
                <div id="scroller">
                    <ul>
                    </ul>
                </div>
            </div>
            <!--<div class="arrow_down" tapmode=""></div>-->
        </nav>
    </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/alpenlicebe.js"></script>
<script type="text/javascript" src="../script/zepto.min.js"></script>
<script type="text/javascript" src="../script/hashes.min.js"></script>
<script type="text/javascript" src="../script/iscroll.js"></script>
<script type="text/javascript">
    apiready = function() {
        /*如果用户处理了，进行刷新*/
        api.addEventListener({
            name: 'Alpe_Event_yq_dosomething'
        }, function(ret) {
            if (ret) {
                goto_gotoChangeDealDataCountFun();
            }
        });
        /*注册监听事件-用户登录*/
        api.addEventListener({
            name: 'Alpe_Event_UserLogin'
        }, function(ret) {
            if (ret) {
                //		   		$("#pageIndex").val(0);
                //	        	$("#main_content").html("");
                //	        	$("#textTip").html("正在加载..");
                ////	            goto_loadDataFun();
                //     alert('我已登录2');
                goto_getNoDealDataCountFun();
                //		alert('222222');
            }
        });
        if ('' == Alpe_getLocalStorge('sys_userID')) {
            var delay = 0;
            if ("ios" != api.systemType) {
                delay = 300;
                alert("请登录");
            }
            api.openWin({
                name: 'login',
                url: './login.html',
                bounces: false,
                reload: true,
                rect: {
                    x: 0,
                    y: 0,
                    w: 'auto',
                    h: 'auto'
                },
                delay: delay
            });

        } else {
            /*初始化加载数据*/
            goto_getNoDealDataCountFun();
        }
    }

    var myScroll = false;


    function goto_gotoChangeDealDataCountFun() {
        var MD5 = new Hashes.MD5;
        var access_token = Alpe_getLocalStorge("access_token");
        var admin_id = Alpe_getLocalStorge("admin_id");
        var sign = MD5.hex(access_token + admin_id + 'deal/infoTotal1.0hzqingbao');

        var url = Alpe_ApiUrl + 'r=datas/infoTotal&access_token=' + access_token + '&admin_id=' + admin_id +
            '&v=1.0&sign=' + sign;
        api.ajax({
            url: url,
            method: 'get',
            cache: false,
            timeout: 30,
            dataType: 'json'
        }, function(ret, err) {
            if (ret.success == '100') {
                var topMenu = [{
                    'cateID': '1',
                    'cateName': '待处置'
                }, {
                    'cateID': '2',
                    'cateName': '已处置'
                }, {
                    'cateID': '3',
                    'cateName': '处置完毕'
                }];
                for (var idx in topMenu) {
                    var module = topMenu[idx];
                    var cateID = module["cateID"];;
                    $("#cateID" + cateID).html(ret.list[idx]);
                }
            }
        })

    }


    function goto_getNoDealDataCountFun() {
        var MD5 = new Hashes.MD5;
        var access_token = Alpe_getLocalStorge("access_token");
        var admin_id = Alpe_getLocalStorge("admin_id");
        var sign = MD5.hex(access_token + admin_id + 'datas/infoTotal1.0syjqingbao');

        var url = Alpe_ApiUrl + 'r=datas/infoTotal&access_token=' + access_token + '&admin_id=' + admin_id +
            '&v=1.0&sign=' + sign;
        console.log(url);
        api.ajax({
            url: url,
            method: 'get',
            cache: false,
            timeout: 30,
            dataType: 'json'
        }, function(ret, err) {
            if (ret.success == '100') {
                var topMenu = [{
                    'cateID': '1',
                    'cateName': '待处置'
                }, {
                    'cateID': '2',
                    'cateName': '已处置'
                }, {
                    'cateID': '3',
                    'cateName': '处置完毕'
                }];
                var navHtml = '',
                    frames = [];
                for (var idx in topMenu) {
                    var module = topMenu[idx];
                    var cateID = module["cateID"];;
                    var cateName = module["cateName"];

                    var active = idx == 0 ? 'nav_active' : '',
                        frame = {};
                    navHtml += '<li data-index="' + idx + '" id="' + cateID + '" class="' + active + '" tapmode="" onclick="goto_openFrameFun(this)">' + cateName + '(<span id=cateID' + cateID + '>' + ret.list[idx] + '</span>)</li>';
                    frame.name = 'frame_' + idx;
                    frame.url = idx == 0 ? 'yq_list.html' : 'yq_list.html';
                    frame.pageParam = {
                        infoID: cateID,
                        index: idx
                    };
                    frames.push(frame);
                }
                $("#scroller").find('ul').html(navHtml);
                goto_openFrameGroupFun(frames);

                myScroll = new IScroll('#wrapper', {
                    eventPassthrough: true,
                    scrollX: true,
                    scrollY: false,
                    preventDefault: false
                });
            } else if ("002" == ret.success || "003" == ret.success) {
                goto_openWin_loginWin(ret.message);
            }
        });
    }
    /*初始化frame*/
    function goto_openFrameGroupFun(frames) {

        api.openFrameGroup({
            name: 'groupYQDeal',
            scrollEnabled: true,
            rect: {
                x: 0,
                y: api.pageParam.winY + $("nav").height() + 2,
                w: 'auto',
                h: api.frameHeight - 40
            },
            index: 0,
            preload: 0,
            /*不预加载*/
            frames: frames
        }, function(ret, err) {
            if (ret.index >= 4) {
                myScroll.scrollTo(-$("li").width() * (ret.index - 4), 0, 2000);
            }
            $("#scroller").find('li').removeClass('nav_active').eq(ret.index).addClass('nav_active');
        });
        api.setFrameGroupIndex({ //初始化在第一个
            name: 'groupYQDeal',
            index: 0,
            scroll: true
        });
    }

    /*打开frame*/
    function goto_openFrameFun(obj) {
        try {
            api.setFrameGroupIndex({
                name: 'groupYQDeal',
                index: $(obj).data('index'),
                scroll: true
            });
        } catch (e) {
            api.alert({
                title: '系统提示',
                msg: '错误信息：' + e
            });
        }
    }

    function goto_openWinFun(winIndex) {
        var winName = "yq_listSearch";
        if (1 == winIndex) {
            winName = "yq_listCate";
        } else {
            winName = "yq_listSearch";
        }
        var delay = 0;
        if ("ios" != api.systemType) {
            delay = 300;
        }
        api.openWin({
            name: winName,
            url: "./" + winName + ".html",
            pageParam: {
                winName: winName
            },
            bounces: false,
            vScrollBarEnabled: false,
            hScrollBarEnabled: false,
            reload: true,
            delay: delay
        });
    }
</script>

</html>
